#include "MeasurE616AlgBackDatum.h"


MeasurE616AlgBackDatum::MeasurE616AlgBackDatum(int i): MeasurE616AlgBase(i)
{
}

void MeasurE616AlgBackDatum::operator()(const cv::Mat &srcImgTemp, int id)
{
    qDebug() << "E616 alg back datum start";
    if(!srcImgTemp.data) {
        qDebug() << "input empty image";
        return;
    }

    cv::Mat srcImg = srcImgTemp.clone();

    // back图  SE9  \paras616\back\SE.xml的最后一行 setup1   注意vector<cv::Point2f>& datum要转换到全局图像坐标系下
    std::vector<cv::Rect> rangVec;
    TemplateMatch(srcImg, m_dataAllVec[27],rangVec);

    std::vector<int> paras;
    for(int j=0;j< m_dataAllVec[27].m_edgeParam.cols;j++)
    {
        paras.push_back(m_dataAllVec[27].m_edgeParam.at<int>(5,j));
    }
    std::vector<Point2f> datum;
    MeasurE616EdgeDetect obj;
    obj.GetDatum616(srcImg(rangVec[0]).clone(),paras,datum);
    for(auto ptr=datum.begin();ptr!=datum.end();ptr++)
    {
        ptr->x+=static_cast<float>(rangVec[0].x);
        ptr->y+=static_cast<float>(rangVec[0].y);
    }
    MeasurE616AlgBase::datumBackVec[id]=datum;
    MeasurE616AlgBase::flagVec[id] = true;
    (*MeasurE616AlgBase::cvarptrVec[id]).notify_all();

    qDebug() << "E616 alg back datum end";
}
